﻿using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace VM.Wechat
{
    public class PayInfo
    {
        public PayInfo()
        {


        }
        /// <summary>
        ///  configuration["AppSettings:UserName"];2
        /// </summary>
        /// <param name="Key"></param>
        public static string GetConfigValuesByKey(string Key)
        {

            IConfiguration configuration = new ConfigurationBuilder()
                                        .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                                        .Build();

            string ResStr = configuration[Key];
            return ResStr;

        }
        /// <summary>
        /// 小程序登录API   ConfigProUntil.GetConfigValuesByKey("AppSettings:wxloginurl");
        /// </summary>
        public static string loginUrl = GetConfigValuesByKey("AppSettings:wxloginurl").Equals(DBNull.Value)?"": GetConfigValuesByKey("AppSettings:wxloginurl").ToString();

        /// <summary>
        /// 统一下单API
        /// </summary>
        public static string orderUrl = GetConfigValuesByKey("AppSettings:wxorderurl").Equals(DBNull.Value) ? "" : GetConfigValuesByKey("AppSettings:wxorderurl").ToString();

        /// <summary>
        /// 支付结果通知API
        /// </summary>
        public static string notifyUrl =GetConfigValuesByKey("AppSettings:wxnotifyurl").Equals(DBNull.Value) ? "" : GetConfigValuesByKey("AppSettings:wxnotifyurl").ToString();
        
        /// <summary>
        /// 查询订单API
        /// </summary>
        public static string queryUrl = GetConfigValuesByKey("AppSettings:wxqueryurl").Equals(DBNull.Value) ? "" : GetConfigValuesByKey("AppSettings:wxqueryurl").ToString();

        /// <summary>
        /// 申请退款API
        /// </summary>
        public static string refundUrl = GetConfigValuesByKey("AppSettings:wxrefundurl").Equals(DBNull.Value) ? "" : GetConfigValuesByKey("AppSettings:wxrefundurl").ToString();

        /// <summary>
        /// 退款通知API
        /// </summary>
        public static string refundNotifyUrl = GetConfigValuesByKey("AppSettings:wxrefundnotifyurl").Equals(DBNull.Value) ? "" : GetConfigValuesByKey("AppSettings:wxrefundnotifyurl").ToString();

        /// <summary>
        /// 退款查询API
        /// </summary>
        public static string refundQueryUrl =GetConfigValuesByKey("AppSettings:wxrefundqueryurl").Equals(DBNull.Value) ? "" : GetConfigValuesByKey("AppSettings:wxrefundqueryurl").ToString();

        /// <summary>
        /// 小程序唯一标识
        /// </summary>
        public static string appid =GetConfigValuesByKey("AppSettings:wxappid").Equals(DBNull.Value) ? "" : GetConfigValuesByKey("AppSettings:wxappid").ToString();

        /// <summary>
        /// 小程序的 app secret
        /// </summary>
        public static string secret = GetConfigValuesByKey("AppSettings:wxsecret").Equals(DBNull.Value) ? "" : GetConfigValuesByKey("AppSettings:wxsecret").ToString();

        /// <summary>
        /// 小程序的授权类型 
        /// </summary>
        public static string grantType =GetConfigValuesByKey("AppSettings:wxgrant_type").Equals(DBNull.Value) ? "" : GetConfigValuesByKey("AppSettings:wxgrant_type").ToString();

        /// <summary>
        /// 商户号(微信支付分配的商户号)
        /// </summary>
        public static string mchid = GetConfigValuesByKey("AppSettings:wxmch_id").Equals(DBNull.Value) ? "" :  GetConfigValuesByKey("AppSettings:wxmch_id").ToString();

        /// <summary>
        ///商户平台设置的密钥key
        /// </summary>
        public static string key = GetConfigValuesByKey("AppSettings:wxkey").Equals(DBNull.Value) ? "" : GetConfigValuesByKey("AppSettings:wxkey").ToString();

        /// <summary>
        /// 随机字符串不长于 32 位
        /// </summary>
        public static string nonceStr = PayHelper.GetNonceStr();

        /// <summary>
        /// 时间戳 从1970年1月1日00:00:00至今的秒数,即当前的时间
        /// </summary>
        public static string timeStamp = PayHelper.GetTimeStamp();

        /// <summary>
        /// 终端IP APP和网页支付提交用户端IP，
        /// </summary>
        public static string addrIp = PayHelper.GetIP;

        /// <summary>
        /// 交易类型 小程序取值如下：JSAPI
        /// </summary>
        public static string tradeType = "JSAPI";

        /// <summary>
        /// 签名类型 默认为MD5，支持HMAC-SHA256和MD5。
        /// </summary>
        public static string signType = "MD5";

        /// <summary>
        /// 商品描述 商品简单描述，该字段请按照规范传递
        /// </summary>
        public static string body = "订单支付";

        /// <summary>
        /// 附加数据 在查询API和支付通知中原样返回
        /// </summary>
        public static string attach = "微信支付信息";

        /// <summary>
        /// 签名，参与签名参数：appid，mch_id，transaction_id，out_trade_no，nonce_str，key
        /// </summary>
        public string sign = "";

        /// <summary>
        /// 微信订单号，优先使用
        /// </summary>
        public static string transactionid = "";

        /// <summary>
        /// 商户系统内部订单号
        /// </summary>
        public static string out_trade_no = "";

        /// <summary>
        /// 商户退款单号
        /// </summary>
        public static string out_refund_no = "";

        /// <summary>
        /// 退款金额
        /// </summary>
        public static decimal refundfee;

        /// <summary>
        /// 订单金额
        /// </summary>
        public static decimal totalfee;

    }
}
